
package com.udc.medLine.persistence;

import java.util.List;

import com.udc.medLine.entity.Item;


public class ItemDAO implements DAO {
	private Item item;
	Bd banco;
	
	public ItemDAO(){
		item = new Item();
		try{
			banco = Bd.getInstance();
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public Item getItem() {
		return item;
	}

	public void setItem(Item item) {
		this.item = item;
	}

	public void insert() throws Exception {
		banco.insert(item);
	}

	public void delete() throws Exception {
		banco.delete(item);
	}
	
	public void update() throws Exception {
		banco.update(item);
	}
	
	public List search(String hql) throws Exception {
		List lista;
		lista = banco.getList(hql);		
		return lista;
	}
	
	public Item retrive() throws Exception {
		return (Item) banco.retrieve(item, item.getId()+"");
	}
	
}
